#include <mutex>
#include <shared_mutex>

class R {
  mutable std::shared_timed_mutex mut;
  /* 数据 */
public:
  R &operator=(const R &other) {
    // 要求排他性所有权以写入 *this
    std::unique_lock<std::shared_timed_mutex> lhs(mut, std::defer_lock);
    // 要求共享所有权以读取 other
    std::shared_lock<std::shared_timed_mutex> rhs(other.mut, std::defer_lock);
    std::lock(lhs, rhs);
    /* 赋值数据 */
    return *this;
  }
};

int main() { R r; }
